﻿#region Using
using System;
using System.Collections.Generic;
using SilverCrmSoap.CrmSdk;

#endregion

namespace Linq2Crm
{
	public sealed partial class DomainObjectContext
	{
		private static readonly Lazy<DomainObjectContext> InstanceHolder = new Lazy<DomainObjectContext>(() => new DomainObjectContext());
		private readonly Dictionary<string, EntityMetadata> _attributesList = new Dictionary<string, EntityMetadata>();
		private readonly Dictionary<string, ManyToManyRelationshipMetadata> _manyToManyRelationshipMetadatas = new Dictionary<string, ManyToManyRelationshipMetadata>();

		private DomainObjectContext()
		{
			CompleteQueuePostback = new Queue<CountedActionCallback>();
			GetRecordsSeed = 250;
		}

		public static IOrganizationService OrganizationService { get; set; }

		public static DomainObjectContext Instance
		{
			get
			{
				return OrganizationService == null
					       ? null
					       : InstanceHolder.Value;
			}
		}
	}
}